home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / GXMath.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-06  |  6.9 KB  |  204 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        GXMath.h
  3.  
  4.      Contains:    QuickDraw GX math routine interfaces.
  5.  
  6.      Version:    Technology:    Quickdraw GX 1.1
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __GXMATH__
  21. #define __GXMATH__
  22.  
  23.  
  24. #ifndef __CONDITIONALMACROS__
  25. #include <ConditionalMacros.h>
  26. #endif
  27.  
  28. #ifndef __TYPES__
  29. #include <Types.h>
  30. #endif
  31.  
  32. #ifndef __FIXMATH__
  33. #include <FixMath.h>
  34. #endif
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40. #if PRAGMA_ALIGN_SUPPORTED
  41. #pragma options align=mac68k
  42. #endif
  43.  
  44. #if PRAGMA_IMPORT_SUPPORTED
  45. #pragma import on
  46. #endif
  47.  
  48. #if defined(__MWERKS__) && GENERATING68K
  49.     #pragma push
  50.     #pragma pointers_in_D0
  51. #endif
  52.  
  53. #define mathTypesIncludes
  54. /* old header = math types */
  55.  
  56. struct gxPoint {
  57.     Fixed                            x;
  58.     Fixed                            y;
  59. };
  60. typedef struct gxPoint gxPoint;
  61.  
  62. typedef unsigned short gxColorValue;
  63.  
  64. struct gxPolar {
  65.     Fixed                            radius;
  66.     Fixed                            angle;
  67. };
  68. struct gxMapping {
  69.     Fixed                            map[3][3];
  70. };
  71. typedef struct gxPolar gxPolar;
  72.  
  73. typedef struct gxMapping gxMapping;
  74.  
  75. #define gxColorValue1 ((gxColorValue) 0x0000FFFF)
  76. #define gxPositiveInfinity ((long) 0x7FFFFFFFL)
  77. #define gxNegativeInfinity ((long) 0x80000000L)
  78. #define mathRoutinesIncludes
  79. /* old header = math routines */
  80.  
  81. extern gxMapping *CopyToMapping(gxMapping *target, const gxMapping *source)
  82.  THREEWORDINLINE(0x303C, 0x31, 0xA832);
  83. extern gxMapping *InvertMapping(gxMapping *target, const gxMapping *source)
  84.  THREEWORDINLINE(0x303C, 0x32, 0xA832);
  85. extern gxMapping *MapMapping(gxMapping *target, const gxMapping *source)
  86.  THREEWORDINLINE(0x303C, 0x33, 0xA832);
  87. extern gxMapping *MoveMapping(gxMapping *target, Fixed hOffset, Fixed vOffset)
  88.  THREEWORDINLINE(0x303C, 0x34, 0xA832);
  89. extern gxMapping *MoveMappingTo(gxMapping *target, Fixed hPosition, Fixed vPosition)
  90.  THREEWORDINLINE(0x303C, 0x35, 0xA832);
  91. extern gxMapping *NormalizeMapping(gxMapping *target)
  92.  THREEWORDINLINE(0x303C, 0x36, 0xA832);
  93. extern gxMapping *RotateMapping(gxMapping *target, Fixed angle, Fixed xCenter, Fixed yCenter)
  94.  THREEWORDINLINE(0x303C, 0x37, 0xA832);
  95. extern gxMapping *ScaleMapping(gxMapping *target, Fixed hFactor, Fixed vFactor, Fixed xCenter, Fixed yCenter)
  96.  THREEWORDINLINE(0x303C, 0x38, 0xA832);
  97. extern gxMapping *ResetMapping(gxMapping *target)
  98.  THREEWORDINLINE(0x303C, 0x39, 0xA832);
  99. extern gxMapping *SkewMapping(gxMapping *target, Fixed skewX, Fixed skewY, Fixed xCenter, Fixed yCenter)
  100.  THREEWORDINLINE(0x303C, 0x3a, 0xA832);
  101. extern void MapPoints(const gxMapping *source, long count, gxPoint vector[])
  102.  THREEWORDINLINE(0x303C, 0x3b, 0xA832);
  103. extern short FirstBit(unsigned long x)
  104.  THREEWORDINLINE(0x303C, 0x3c, 0xA832);
  105. extern short WideScale(const wide *source)
  106.  THREEWORDINLINE(0x303C, 0x3d, 0xA832);
  107. extern short LinearRoot(Fixed first, Fixed last, Fract t[])
  108.  THREEWORDINLINE(0x303C, 0x3e, 0xA832);
  109. extern short QuadraticRoot(Fixed first, Fixed control, Fixed last, Fract t[])
  110.  THREEWORDINLINE(0x303C, 0x3f, 0xA832);
  111. extern gxPoint *PolarToPoint(const gxPolar *ra, gxPoint *xy)
  112.  THREEWORDINLINE(0x303C, 0x40, 0xA832);
  113. extern gxPolar *PointToPolar(const gxPoint *xy, gxPolar *ra)
  114.  THREEWORDINLINE(0x303C, 0x41, 0xA832);
  115. extern Fract FractCubeRoot(Fract source)
  116.  THREEWORDINLINE(0x303C, 0x42, 0xA832);
  117. extern Fract FractDivide(Fract dividend, Fract divisor)
  118.  THREEWORDINLINE(0x303C, 0x43, 0xA832);
  119. extern Fract FractMultiply(Fract multiplicand, Fract multiplier)
  120.  THREEWORDINLINE(0x303C, 0x44, 0xA832);
  121. extern Fract FractSineCosine(Fixed degrees, Fract *cosine)
  122.  THREEWORDINLINE(0x303C, 0x45, 0xA832);
  123. extern Fract FractSquareRoot(Fract source)
  124.  THREEWORDINLINE(0x303C, 0x46, 0xA832);
  125. extern Fixed FixedDivide(Fixed dividend, Fixed divisor)
  126.  THREEWORDINLINE(0x303C, 0x47, 0xA832);
  127. extern Fixed FixedMultiply(Fixed multiplicand, Fixed multiplier)
  128.  THREEWORDINLINE(0x303C, 0x48, 0xA832);
  129. /* This next call is (source * multiplier / divisor) -- it avoids underflow, overflow by using wides */
  130. extern long MultiplyDivide(long source, long multiplier, long divisor)
  131.  THREEWORDINLINE(0x303C, 0x49, 0xA832);
  132. extern unsigned long Magnitude(long deltaX, long deltaY)
  133.  THREEWORDINLINE(0x303C, 0x4a, 0xA832);
  134. extern long VectorMultiplyDivide(long count, const long *vector1, long step1, const long *vector2, long step2, long divisor)
  135.  THREEWORDINLINE(0x303C, 0x4b, 0xA832);
  136.  
  137.  
  138. /* wide operations are defined within FixMath.h only for PowerPC */
  139. #if    !GENERATINGPOWERPC
  140. extern wide *WideAdd(wide *target, const wide *source)
  141.  THREEWORDINLINE(0x303C, 0x4c, 0xA832);
  142. extern short WideCompare(const wide *target, const wide *source)
  143.  THREEWORDINLINE(0x303C, 0x4d, 0xA832);
  144. extern wide *WideNegate(wide *target)
  145.  THREEWORDINLINE(0x303C, 0x4e, 0xA832);
  146. extern wide *WideShift(wide *target, long shift)
  147.  THREEWORDINLINE(0x303C, 0x4f, 0xA832);
  148. extern unsigned long WideSquareRoot(const wide *source)
  149.  THREEWORDINLINE(0x303C, 0x50, 0xA832);
  150. extern wide *WideSubtract(wide *target, const wide *source)
  151.  THREEWORDINLINE(0x303C, 0x51, 0xA832);
  152. extern wide *WideMultiply(long multiplicand, long multiplier, wide *target)
  153.  THREEWORDINLINE(0x303C, 0x52, 0xA832);
  154. /* returns the quotient */
  155. extern long WideDivide(const wide *dividend, long divisor, long *remainder)
  156.  THREEWORDINLINE(0x303C, 0x53, 0xA832);
  157. /* quotient replaces dividend */
  158. extern wide *WideWideDivide(wide *dividend, long divisor, long *remainder)
  159.  THREEWORDINLINE(0x303C, 0x55, 0xA832);
  160. #endif
  161.  
  162.  
  163. extern wide *VectorMultiply(long count, const long *vector1, long step1, const long *vector2, long step2, wide *dot)
  164.  THREEWORDINLINE(0x303C, 0x54, 0xA832);
  165. extern unsigned long RandomBits(long count, long focus)
  166.  THREEWORDINLINE(0x303C, 0x56, 0xA832);
  167. extern void SetRandomSeed(const wide *seed)
  168.  THREEWORDINLINE(0x303C, 0x57, 0xA832);
  169. extern wide *GetRandomSeed(wide *seed)
  170.  THREEWORDINLINE(0x303C, 0x58, 0xA832);
  171. #define FixedRound(a) ((short)((Fixed)(a) + fixed1/2 >> 16))
  172. #define FixedSquareRoot(a) ((Fixed)FractSquareRoot(a) + 64 >> 7)
  173. #define FixedTruncate(a) ((short)((Fixed)(a) >> 16))
  174. #define FixedToFract(a) ((Fract)(a) << 14)
  175. #define FractToFixed(a) ((Fixed)(a) + 8192L >> 14)
  176. #define FixedToInt(a) ((short)((Fixed)(a) + fixed1/2 >> 16))
  177. #define IntToFixed(a) ((Fixed)(a) << 16)
  178. #define FixedToFloat(a) ((float)(a) / fixed1)
  179. #define FloatToFixed(a) ((Fixed)((float)(a) * fixed1))
  180. #define FractToFloat(a) ((float)(a) / fract1)
  181. #define FloatToFract(a) ((Fract)((float)(a) * fract1))
  182. #define ColorToFract(a) (((Fract) (a) << 14) + ((Fract)(a) + 2 >> 2))
  183. #define FractToColor(a) ((gxColorValue) ((a) - ((a) >> 16) + 8191 >> 14))
  184. #define ff(a) IntToFixed(a)
  185. #define fl(a) FloatToFixed(a)
  186.  
  187. #if defined(__MWERKS__) && GENERATING68K
  188.     #pragma pop
  189. #endif
  190.  
  191. #if PRAGMA_IMPORT_SUPPORTED
  192. #pragma import off
  193. #endif
  194.  
  195. #if PRAGMA_ALIGN_SUPPORTED
  196. #pragma options align=reset
  197. #endif
  198.  
  199. #ifdef __cplusplus
  200. }
  201. #endif
  202.  
  203. #endif /* __GXMATH__ */
  204.